package com.x.epspace.common;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

public class JspTool {
	
	public static String getEncode(String str){
		try {
			str=URLEncoder.encode(URLEncoder.encode(str, "utf-8"), "utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return str;
	}
	
	public static Object nvl(Object obj,Object reObj){
		if(obj!=null){
			if(!"".equals(obj.toString())){
				return obj;
			}
		}else {
			if(reObj!=null){
				return reObj;
			}else {
				return new HashMap();
			}
		}
		return null;
	}
	
	
	public static Integer getByteLength(String str){
		if(Tool.isNotNullOrEmpty(str)){
			try {
				int num=str.getBytes("GBK").length;
				return num;
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return 0;
	}
	
	public static Object getMapValue(Map params,String key){
		Object obj= null;
		if(params!=null){
			obj=params.get(key);
		}
		return obj;
	}
	
}
